﻿using DataChangeTools.Api.Models;
using DataChangeTools.Api.Models.Resp;
using DataChangeTools.Api.Service;
using DataChangeTools.Utils.Constants;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataChangeTools.Api.Services
{
    public class AutoUpdaterService : BaseService<VersionResp>, IAutoUpdaterService
    {
        private readonly HttpRestClient client;

        public AutoUpdaterService(HttpRestClient client) : base(client, "Version")
        {
            this.client = client;
        }


        public async Task<HttpResponseDTO<VersionResp>> GetCheckInfoAsync(string OldVersion)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.Post;
            request.Route = AutoUpdaterConstants.CheckUrl;
            request.Parameter = new
            {
                OldVserion = OldVersion
            };
            return await client.ExecuteAsync<VersionResp>(request);
        }
    }
}
